package org.apache.commons.httpclient.util;

import java.util.ArrayList;
import java.util.List;
import org.apache.commons.httpclient.NameValuePair;

public class ParameterParser
{
  private char[] chars = null;
  private int i1 = 0;
  private int i2 = 0;
  private int len = 0;
  private int pos = 0;

  private String getToken(boolean paramBoolean)
  {
    while ((this.i1 < this.i2) && (Character.isWhitespace(this.chars[this.i1])))
      this.i1 = (1 + this.i1);
    while ((this.i2 > this.i1) && (Character.isWhitespace(this.chars[(this.i2 - 1)])))
      this.i2 -= 1;
    if ((paramBoolean) && (this.i2 - this.i1 >= 2) && (this.chars[this.i1] == '"') && (this.chars[(this.i2 - 1)] == '"'))
    {
      this.i1 = (1 + this.i1);
      this.i2 -= 1;
    }
    String str = null;
    if (this.i2 >= this.i1)
      str = new String(this.chars, this.i1, this.i2 - this.i1);
    return str;
  }

  private boolean hasChar()
  {
    if (this.pos < this.len);
    for (int i = 1; ; i = 0)
      return i;
  }

  private boolean isOneOf(char paramChar, char[] paramArrayOfChar)
  {
    int i = 0;
    for (int j = 0; ; ++j)
    {
      if (j < paramArrayOfChar.length)
      {
        if (paramChar != paramArrayOfChar[j])
          continue;
        i = 1;
      }
      return i;
    }
  }

  private String parseQuotedToken(char[] paramArrayOfChar)
  {
    this.i1 = this.pos;
    this.i2 = this.pos;
    int i = 0;
    int j = 0;
    label20: char c;
    if (hasChar())
    {
      c = this.chars[this.pos];
      if ((i != 0) || (!(isOneOf(c, paramArrayOfChar))))
        break label58;
    }
    return getToken(true);
    if ((j == 0) && (c == '"'))
    {
      label58: if (i != 0)
        break label111;
      i = 1;
    }
    label75: if ((j == 0) && (c == '\\'));
    for (j = 1; ; j = 0)
    {
      this.i2 = (1 + this.i2);
      this.pos = (1 + this.pos);
      break label20:
      label111: i = 0;
      break label75:
    }
  }

  private String parseToken(char[] paramArrayOfChar)
  {
    this.i1 = this.pos;
    this.i2 = this.pos;
    while (true)
    {
      if ((!(hasChar())) || (isOneOf(this.chars[this.pos], paramArrayOfChar)))
        return getToken(false);
      this.i2 = (1 + this.i2);
      this.pos = (1 + this.pos);
    }
  }

  public List parse(String paramString, char paramChar)
  {
    if (paramString == null);
    for (Object localObject = new ArrayList(); ; localObject = parse(paramString.toCharArray(), paramChar))
      return localObject;
  }

  public List parse(char[] paramArrayOfChar, char paramChar)
  {
    if (paramArrayOfChar == null);
    for (Object localObject = new ArrayList(); ; localObject = parse(paramArrayOfChar, 0, paramArrayOfChar.length, paramChar))
      return localObject;
  }

  public List parse(char[] paramArrayOfChar, int paramInt1, int paramInt2, char paramChar)
  {
    if (paramArrayOfChar == null);
    ArrayList localArrayList;
    for (Object localObject = new ArrayList(); ; localObject = localArrayList)
    {
      return localObject;
      localArrayList = new ArrayList();
      this.chars = paramArrayOfChar;
      this.pos = paramInt1;
      this.len = paramInt2;
      while (hasChar())
      {
        char[] arrayOfChar1 = new char[2];
        arrayOfChar1[0] = '=';
        arrayOfChar1[1] = paramChar;
        String str1 = parseToken(arrayOfChar1);
        String str2 = null;
        if ((hasChar()) && (paramArrayOfChar[this.pos] == '='))
        {
          this.pos = (1 + this.pos);
          char[] arrayOfChar2 = new char[1];
          arrayOfChar2[0] = paramChar;
          str2 = parseQuotedToken(arrayOfChar2);
        }
        if ((hasChar()) && (paramArrayOfChar[this.pos] == paramChar))
          this.pos = (1 + this.pos);
        if ((str1 == null) || ((str1.equals("")) && (str2 == null)))
          continue;
        localArrayList.add(new NameValuePair(str1, str2));
      }
    }
  }
}

/* Location:           E:\Desktop\Android\wordstd\classes_dex2jar.jar
 * Qualified Name:     org.apache.commons.httpclient.util.ParameterParser
 * JD-Core Version:    0.5.3
 */